package com.text.day2_3.pk;


import java.util.Random;

public class PkManage {
    public static void pk(Hero hero1, Hero hero2) {
        int a = 1;
        while (hero1.isAlive() && hero2.isAlive()) {
            System.out.println();
            System.out.println(hero1.getName() + "hp:" + hero1.getHp() + "---- VS ----" + hero2.getName() + "hp:" + hero2.getHp());
            System.out.println("=========第" + a + "回合，ready fight=========");
            if (a % 2 == 1) {
                hero1.fight(hero2);
            } else {
                hero2.fight(hero1);
            }
            a++;
        }
    }
    public static void main(String[] args) {
        Random random = new Random();
        Hero hero1 = new Hero("一号", 100, random.nextInt(20) + 20);
        Hero hero2 = new Hero("二号", 100, random.nextInt(20) + 20);
        System.out.println(hero1);
        System.out.println(hero2);
        System.out.println("==========PK===========");
        pk(hero1,hero2);
    }
}
